//
//  ADTableViewCell.m
//  土巴兔
//
//  Created by 千锋 on 15/12/29.
//  Copyright (c) 2015年 IOS1503薛凯. All rights reserved.
//

#import "ADTableViewCell.h"
#import "Default.h"
#import "ADModel.h"
#import "UIImageView+WebCache.h"
@implementation ADTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}
-(void) createUI{
    _scrollview=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, DEVICEWIDTH, DEVICEHEIGHT/3)];
    _scrollview.contentSize=CGSizeMake(DEVICEWIDTH*3,DEVICEHEIGHT/3);
    _scrollview.pagingEnabled=YES;
    _scrollview.showsHorizontalScrollIndicator=NO;
    [self.contentView addSubview:_scrollview];
//    //实例化第一个图片
//    _firstImageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, DEVICEWIDTH,DEVICEHEIGHT/3)];
//    [_scrollview addSubview:_firstImageView];
//     //实例化第二个图片
//    _secondImageView=[[UIImageView alloc] initWithFrame:CGRectMake(DEVICEWIDTH, 0, DEVICEWIDTH, DEVICEHEIGHT/3)];
//    [_scrollview addSubview:_secondImageView];
//     //实例化第三个图片
//    _thirdImageView=[[UIImageView alloc] initWithFrame:CGRectMake(DEVICEWIDTH*2, 0, DEVICEWIDTH, DEVICEHEIGHT/3)];
//    [_scrollview addSubview:_thirdImageView];
//     //实例化第四个图片
////    _fouthImageView=[[UIImageView alloc] initWithFrame:CGRectMake(DEVICEWIDTH*3, 0, DEVICEWIDTH, DEVICEHEIGHT/3)];
////    [_scrollview addSubview:_fouthImageView];
    
}
- (void)relayoutWithImages:(NSArray*)imageArray{
    NSLog(@"%d",imageArray.count);
    _scrollview.contentSize=CGSizeMake(DEVICEWIDTH*imageArray.count,DEVICEHEIGHT/3);
    for (int i=0; i<imageArray.count; i++) {
        UIImageView* imageview=[[UIImageView alloc] init];
        imageview.frame=CGRectMake(DEVICEWIDTH*i, 0, DEVICEWIDTH, DEVICEHEIGHT/3);
        [imageview sd_setImageWithURL:imageArray[i]];
        [self.scrollview addSubview:imageview];
    }
//    [_fouthImageView sd_setImageWithURL:imageArray[3]];
}
@end
